package io.renren.modules.edu.controller;

import io.renren.common.utils.PageData;
import io.renren.common.utils.Result;
import io.renren.modules.edu.dto.TEduSalaryDTO;
import io.renren.modules.edu.service.TEduSalaryService;
import io.renren.modules.edu.vo.TEduSalaryVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 薪资表
 *
 * @author zwp zwp
 * @since 1.0.0 2022-07-11
 */
@RestController
@RequestMapping("edu/tedusalary")
@Api(tags="薪资表")
public class TEduSalaryController {

    @Autowired
    private TEduSalaryService tEduSalaryService;

    /**
     * 获取对应用户的薪资表
     * @param params
     * @return
     */
    @GetMapping("querySalaryPage")
    public Result<PageData<TEduSalaryVO>> querySalaryPage(@RequestParam Map<String, Object> params) {
        PageData<TEduSalaryVO> eduSalaryVOPageData = tEduSalaryService.querySalaryPage(params);
        return new Result<PageData<TEduSalaryVO>>().ok(eduSalaryVOPageData);
    }

    /**
     * 获取对应年份、月份 用户的薪资表
     * @param params
     * @return
     */
    @GetMapping("querySalaryByYearMonthPage")
    public Result<PageData<TEduSalaryVO>> querySalaryByYearMonthPage(@RequestParam Map<String, Object> params) {
        PageData<TEduSalaryVO> eduSalaryVOPageData = tEduSalaryService.querySalaryByYearMonthPage(params);
        return new Result<PageData<TEduSalaryVO>>().ok(eduSalaryVOPageData);
    }

    /**
     * 确认薪资
     * @param id
     * @return
     */
    @PostMapping("/confirmSalary/{id}")
    public Result<Map<String, Object>> confirmSalary(@PathVariable Long id) {
        tEduSalaryService.confirmSalary(id);
        return new Result<Map<String, Object>>();
    }

    /**
     * 薪资录入
     * @param dto
     * @return
     */
    @PostMapping("onSubmit")
    public Result<Map<String, Object>> onSubmit(@RequestBody TEduSalaryDTO dto) {
        tEduSalaryService.onSubmit(dto);
        return new Result<Map<String, Object>>();
    }
}
